home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10068 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.0 KB  |  30 lines

  1. Newsgroups: comp.lang.c
  2. Path: phcoms4.seri.philips.nl!misf1!Pvestjen
  3. From: Pvestjen@ms.philips.nl (Patrick Vestjens)
  4. Subject: Re: Checking for Ilegal Input
  5. Message-ID: <1996Mar14.154854.15488@ms.philips.nl>
  6. Sender: news@ms.philips.nl
  7. Organization: Philips Medical Systems, Best
  8. X-Newsreader: TIN [version 1.2 PL2]
  9. References: <313855C7.5E86@aol.com> <4i49fa$819@info-server.bbn.com>
  10. Date: Thu, 14 Mar 1996 15:48:54 GMT
  11.  
  12. Anita Hsiung (ahsiung@bbn.com) wrote:
  13. : Why not try:
  14.  
  15. : char   *resp;  /* do some memory allocation */
  16. : while ( (resp < '0') || (resp > '15') ) {
  17. :   printf("Enter a again:");
  18. :   scanf("%s", &resp);
  19. : }
  20.  
  21. Hm, are you sure about this? First of all you are comparing a pointer to
  22. a character to a character constant. Then you compare the same pointer
  23. to a multi-byte character that probably should not be a multi-byte
  24. character. Finally, you are storing the string just read at the address
  25. of the pointer to the first character of the string, this should have
  26. been 'resp' instead of '&resp' in my opinion.
  27.  
  28. Regards, Patrick.
  29.  
  30.